package codificacion;

public class Codificar {
	
	public String desencriptar(String palabra){
		
		char[] caracter = palabra.toCharArray();
			
		for (int i = 0 ; i < palabra.length(); i++){
			if(caracter[i]=='P'){caracter[i]='1';
				}else if(caracter[i]=='E'){caracter[i]='2';			
				}else if(caracter[i]=='R'){caracter[i]='3';			
				}else if(caracter[i]=='U'){caracter[i]='4';			
				}else if(caracter[i]=='A'){caracter[i]='5';			
				}else if(caracter[i]=='N'){caracter[i]='6';			
				}else if(caracter[i]=='I'){caracter[i]='7';			
				}else if(caracter[i]=='T'){caracter[i]='8';			
				}else if(caracter[i]=='O'){caracter[i]='9';			
				}else if(caracter[i]=='X'){caracter[i]='0';			
			}
		}
		
		String encriptados = new String(caracter);

		return encriptados;
		}
	

		
		public String encriptar(String palabra){
			
			char[] caracter = palabra.toCharArray();
				
			for (int i = 0 ; i < palabra.length(); i++){
				if(caracter[i]=='1'){caracter[i]='P';
					}else if(caracter[i]=='2'){caracter[i]='E';			
					}else if(caracter[i]=='3'){caracter[i]='R';			
					}else if(caracter[i]=='4'){caracter[i]='U';			
					}else if(caracter[i]=='5'){caracter[i]='A';			
					}else if(caracter[i]=='6'){caracter[i]='N';			
					}else if(caracter[i]=='7'){caracter[i]='I';			
					}else if(caracter[i]=='8'){caracter[i]='T';			
					}else if(caracter[i]=='9'){caracter[i]='O';			
					}else if(caracter[i]=='0'){caracter[i]='X';			
				}
			}
			
			String desencriptados = new String(caracter);

			return desencriptados;
			}
	}
	


